package com.cm.course.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.cm.course.entity.WrongQuestion;
import com.cm.course.service.WrongService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * @author xdf
 * @date 2023-06-22
 */
@RestController
@RequestMapping("/wrong")
public class WrongController {

  @Resource WrongService wrongService;

  /**
   * 按难度获取某学生的错题数量
   * @param studentId
   * @return
   */
  @GetMapping("/num/{studentId}")
  public Map<String, Integer> getWrongQuestionNumberByDifficulty(@PathVariable Long studentId) {
    return wrongService.getWrongQuestionNumberByDifficulty(studentId);
  }

  /**
   * 按知识点获取某学生的错题数量
   * @param studentId
   * @return
   */
  @GetMapping("/points/{studentId}")
  public List<String> getPoints(@PathVariable Long studentId) {
    return wrongService.getPoints(studentId);
  }

  /**
   * 分页获取某学生的错题列表
   * @param studentId
   * @param current
   * @param size
   * @return
   */
  @GetMapping("/question/{studentId}/{current}/{size}")
  public Page<WrongQuestion> getWrongQuestion(
      @PathVariable Long studentId, @PathVariable Long current, @PathVariable Long size) {
    return wrongService.getWrongQuestion(studentId, current, size);
  }
}
